package com.leyou.item.service.impl;

import com.leyou.item.mapper.SpecGroupMapper;
import com.leyou.item.mapper.SpecParamMapper;
import com.leyou.item.service.SpecService;
import com.leyou.pojo.SpecGroup;
import com.leyou.pojo.SpecParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author XiaoLuo
 * @ClassName: SpecServiceImpl
 * @Description: ${todo}
 * @date 2019/4/17 17:31
 */
@Service
public class SpecServiceImpl implements SpecService {

	/**
	 * 根据商品分类ID查询分类对应的规格组
	 */
	@Autowired
	private SpecGroupMapper specGroupMapper;
	@Override public List<SpecGroup> querySpecGroups(Long cid) {
		SpecGroup specGroup = new SpecGroup();
		specGroup.setCid(cid);
		return this.specGroupMapper.select(specGroup) ;
	}

	/**
	 * g根据商品规格组的ID查询对应的参数
	 * @param gid
	 * @return
	 */
	@Autowired
	private SpecParamMapper specParamMapper;
	@Override public List<SpecParam> querySpecParam( Long gid,Long cid,
			Boolean searching, Boolean generic) {
		SpecParam specParam = new SpecParam();
		specParam.setGroupId(gid);
		specParam.setCid(cid);
		specParam.setSearching(searching);
		specParam.setGeneric(generic);
		return this.specParamMapper.select(specParam);

	}

}
